import os


def countLine(path):
    with open(path, 'r', encoding="utf-8") as f:
        t = f.readlines()
        ret = 0
        for i in t:
            if (i != "\n") & (i != ""):
                if i[0] != "#":
                    ret = ret + 1
        return ret


def main():
    sum = 0
    for root, dir, files in os.walk(r'D:\git'):
        for file in files:
            if file.split(".")[-1] in ["py"]:
                path = os.path.join(root, file)
                x = countLine(path)
                sum = sum + x
                print("{} --- {} lines".format(path, x))
    print(sum)


if __name__ == "__main__":
    main()
